<?php
	$data = $this->data;
	$filePath = $this->filePath;
?>
<div class="products-list">
	<h2>Danh mục sản phẩm</h2>
	<?php
	$counter = 0;
	foreach ($data as $value) {
		$images = explode('|', $value['hinhAnh'] );
		unset($images[count($images) -1]);
		$linkImg = '/files/'.$value['loaiHang'].'/'.$value['maHang'].'/';
	?>
		
		<div class="product-node <?php echo 'type'.$value['loaiHang'];?>" >
		<div class="product-description">
		<table>
			<tbody>
				<tr>
					<td>
					<?php
					if(isset($images[0]))
						echo 	'<div class="crop-img">
								<a href="/application/index/chi-tiet/id/'.$value['id'].'">
								<img height="140px" style="border:1px solid white;" width="140px" src="'.$linkImg.$images[0].'" onerror="imgError(this)">
								</a>
								</div>';
					else
						echo 	'<div class="crop-img">
								<a href="/application/index/chi-tiet/id/'.$value['id'].'">
								<img height="140px" style="border:1px solid white;" width="140px" src="'.$linkImg.'not-found.jpg" onerror="imgError(this)">
								</a>
								</div>';
					?>
					</td>
					<td style="text-align:justify; ">
						<?php
						echo '<a href="/application/index/chi-tiet/id/'.$value['id'].'"><h3 style="margin-top:0px;">'.$value['ten'].'</h3></a>';
						echo 'Mô tả:'.$value['moTa'];
						echo '<br/>';
						if(((int)$value['soLuong'])>0)	
							echo 'Tình trạng: Còn hàng';
						else
							echo 'Tình trạng: Hết hàng';
						echo '<br/>';
						echo '<br/><b>Giá: '.$value['gia'].' VNĐ</b>';
						?>
					</td>
				</tr>
			</tbody>
		</table>
		</div>
		<?php
			if($value['soLuong'] > 0)
				echo "<img src='/files/availableBanner.png' class='availableBanner'>";
		?>	
		</div>
	<?php	
	}	
	?>
</div>
<style>
	.my-content{
		text-align: left;

	}
	.my-content a:hover{
		cursor: pointer;
	}
</style>
<script>	
function imgError(image){
	image.onerror = "";
	image.src = "/files/not-found.jpg";
	return true;
}

$('img').each(function(){
	// với mỗi hình ảnh.
});
</script>